/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [Frame_4_QuestionPanel.java]
 * Creation Date        [12-Jul-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_04_other.examApp.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

/**
 * 试题和选项面板
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class Frame_4_QuestionPanel extends JPanel implements ActionListener {

	private static final long serialVersionUID = 5765045813473666491L;

	/** 单选按钮组件 */
	private String selectedValue = "";
	private ButtonGroup group = new ButtonGroup();

	/**
	 * 初始化单选按钮
	 */
	private void init() {
		for (int i = 0; i < 4; i++) {
			JRadioButton jrb = new JRadioButton((char) (65 + i) + "");
			group.add(jrb);
			this.add(jrb);
			jrb.addActionListener(this);
		}
	}

	public Frame_4_QuestionPanel() {
		init();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		setSelectedValue(e.getActionCommand());
	}

	public String getSelectedValue() {
		return selectedValue;
	}

	public void setSelectedValue(String selectedValue) {
		this.selectedValue = selectedValue;
	}

	public ButtonGroup getGroup() {
		return group;
	}

	public void setGroup(ButtonGroup group) {
		this.group = group;
	}
}
